<template>
    <div>
        <layout-edit-content title="用户信息编辑">
            <div slot="main">
<#--                <user-form :user-id="userId" :type="type"></user-form>-->
<#--                <${classInfo.className}Form :user-id="userId" :type="type"></${classInfo.className}Form>-->
                <${classInfo.className}Form :entityId="entityId" :type="type"></${classInfo.className}Form>
            </div>
        </layout-edit-content>

        <Table :columns="columns" :data="allList" ref="selection" :loading="searchLoading">

        </Table>

    </div>
</template>

<script>
    import {getUserInfo} from "../../api/user";
    import LayoutEditContent from "../../components/layout/layout-edit-content";
    // import UserForm from "../../components/form/user-form";
    import ${classInfo.className}Form from "../../components/form/${classInfo.className?uncap_first}-form";
    // import {batchDelete, deleteOne, exportToWord,selectAll,selectPage} from "../../api/permission";
    import {batchDelete, deleteOne, exportToWord,selectAll} from "../../api/permission";
    import {update,create,selectPage} from "../../utils/request";
    export default {
        name: "UserInfoEdit",
        components: {
            LayoutEditContent,
            ${classInfo.className}Form },
        created() {
            // this.userId = this.$route.query.userId;
            // if (!!this.userId) {
            //     this.type = 'update';
            // }

            // this.entityId =    this.$route.query.id;
            if (!!this.entityId) {
                this.type = 'update';
            }

            this. selectPage();
        },
        methods:{
            selectPage() {
                this.searchLoading = true;
                selectPage(this.select,this.select.pageNum,
                    this.select.pageSize,this.tableName).then(res => {
                    // this.writerList = res.data.data.list;

                    console.log("res")
                    console.log(res)
                    // this.allList = res.data.data.list;
                    this.allList = res.data.data;

                    console.log( "this.allList")
                    console.log( this.allList)

                    this.total = res.data.data.total;
                    this.searchLoading = false;
                })
            },

            addPermissions(){
                let selectList = this.$refs.selection.getSelection();
                if (selectList.length === 0) {
                    this.$Message.error('请选择要添加的权限');
                    return;
                }

                for (let item of selectList) {
                    this.del.widList.push(item.wid);
                }
            }
        },
        data() {
            return {
                // entityId:'',
                // entityId:this.$route.query.userId,
                entityId:this.$route.query.id,
                tableName:"${classInfo.className?uncap_first}",
                total: 0,
                searchLoading: false,
                userId: '',
                type: 'create',
                select: {
            <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
            <#list classInfo.fieldList as fieldItem >
            ${fieldItem.fieldName}: '',
                </#list>

                </#if>

                pageNum: 1,
                pageSize: 10

            // 会 显示9个 是因为他吗 不是因为后台
            // 确实有问题 ，这里要写10个 ，才是正常的诶
            // 那个控件要改掉他 每页的个数吧
            // 只有 90页  这样显示不全的吧
            // 只要给 total 就可以工作了吧
        },

                columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },

                    <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
                    <#list classInfo.fieldList as fieldItem >
                    {
                        title: '${fieldItem.fieldComment}',
                        key: '${fieldItem.fieldName}',
                        //  slot:"${fieldItem.fieldName}",
                        // 这里要配置 slot 才能被抓到
                        width: 100
                    },
                    </#list>

                    </#if>




                    {
                        title: '操作',
                        // slot: 'action',
                        fixed: 'right',
                        width: 240,
                        align: 'center'
                    }
                    ,
                    {
                        title: '作品',
                        // slot: 'works',
                        // slot 注释掉 就有了
                        width: 300,
                        key: 'works',

                    }
                ],
                allList:[],
            }
        },
    }
</script>

<style scoped>

</style>
